from PySide6.QtGui import QIcon, QPixmap

from sys import argv
from os import path


APPPATH = path.realpath(path.dirname(argv[0]))
if path.isdir(path.join(APPPATH, '_internal')):
    # when it is a pyinstaller-packaged exe file
    RESOURCE_PATH = path.join(APPPATH, '_internal')
else:
    RESOURCE_PATH = APPPATH


def get_icon_by_name(name: str) -> QIcon:
    return QIcon(path.join(RESOURCE_PATH, 'assets', 'images', name))


def get_pixmap_by_name(name: str) -> QPixmap:
    image_path = path.join(RESOURCE_PATH, 'assets', 'images', name)
    return QPixmap(image_path)
